package nc.bs.pub.action;

import java.io.IOException;
import java.util.Hashtable;

import com.fasterxml.jackson.databind.ObjectMapper;

import bip.util.SendToQFKR.ComparisonEnum;
import bip.util.SendToQFKR.FORMresignationEntity;
import bip.util.SendToQFKR.SendToKR;
import nc.bs.dao.BaseDAO;
import nc.bs.pub.compiler.AbstractCompiler2;
import nc.jdbc.framework.processor.ColumnProcessor;
import nc.vo.pub.BusinessException;
import nc.vo.pub.compiler.PfParameterVO;
import nc.vo.trn.transmng.AggStapply;
import nc.vo.uap.pf.PFBusinessException;
import nccloud.itf.hrsscpub.utils.WorkLoadCountUtil;




public class N_6115_SAVE
extends AbstractCompiler2
{
	private Hashtable m_keyHas = null;
	BaseDAO dao=new BaseDAO();










	@Override
	public String getCodeRemark() { return ""; }



	@Override
	public Object runComClass(PfParameterVO vo) throws BusinessException {
		try {
			this.m_tmpVo = vo;
			Object[] retObj = null;
			retObj = (Object[])runClass("nc.impl.trn.transmng.TransmngServiceImpl", "doCommit", "nc.vo.trn.transmng.AggStapply[]:6115", vo, this.m_keyHas);
			WorkLoadCountUtil.count(vo, "COMMIT");

			for (int i = 0; retObj != null && i < retObj.length; i++) {
				if(retObj[i] instanceof AggStapply) {
					AggStapply vos = (AggStapply)retObj[i];
					if(vos.getParentVO().getAttributeValue("pk_org").toString().equals("0001E210000000001I4X")) {
						ObjectMapper objectMapper = new ObjectMapper();
						// 推送数据至EKP
						// 构建FormValuesEntity实例
						FORMresignationEntity formValues = new FORMresignationEntity();
						// 设置各个属性值...
						// 例如：formValues.setFd_3d100d1c7801b4("编码值");
						formValues.setFd_3d100d1c7801b4(vos.getParentVO().getAttributeValue("bill_code").toString());//申请单编码
						String billmakersql="select user_name from sm_user where cuserid = '"+vos.getParentVO().getAttributeValue("billmaker").toString()+"'";
						String billmaker=  (String)dao.executeQuery(billmakersql, new ColumnProcessor());
						formValues.setFd_3d100d220c98c8(billmaker);//申请人
						formValues.setFd_3d100d2341be6e(vos.getParentVO().getAttributeValue("apply_date").toString()+" 00:00:00");//申请时间（格式建议定义为符合日期时间的字符串格式）
						String pk_psnjobsql="select name from bd_psndoc where pk_psndoc = '"+vos.getParentVO().getAttributeValue("pk_psndoc").toString()+"'";
						String pk_psnjob=  (String)dao.executeQuery(pk_psnjobsql, new ColumnProcessor());
						formValues.setFd_3d100d21001220(pk_psnjob);
						String pk_trnstypesql="select trnstypename from hr_trnstype where pk_trnstype = '"+vos.getParentVO().getAttributeValue("pk_trnstype").toString()+"'";
						String pk_trnstype=  (String)dao.executeQuery(pk_trnstypesql, new ColumnProcessor());
						formValues.setFd_3d1031cc2fda64(pk_trnstype);
						String sreasonsql="select name from bd_defdoc where pk_defdoc = '"+vos.getParentVO().getAttributeValue("sreason").toString()+"'";
						String sreason=  (String)dao.executeQuery(sreasonsql, new ColumnProcessor());
						formValues.setFd_3d100d22bb8c40(sreason);
						formValues.setFd_3d1031d9f292bc(vos.getParentVO().getAttributeValue("memo")==null?null:vos.getParentVO().getAttributeValue("memo").toString());
						String oldpk_deptsql="select name from org_dept where pk_dept = '"+(vos.getParentVO().getAttributeValue("oldpk_dept")==null?null:vos.getParentVO().getAttributeValue("oldpk_dept").toString())+"'";
						String oldpk_dept=  (String)dao.executeQuery(oldpk_deptsql, new ColumnProcessor());
						formValues.setFd_3d100ed0324bb0(oldpk_dept);

						String oldpk_psnclsql="select name from bd_psncl where pk_psncl = '"+(vos.getParentVO().getAttributeValue("oldpk_psncl")==null?null:vos.getParentVO().getAttributeValue("oldpk_psncl").toString())+"'";
						String oldpk_psncl=  (String)dao.executeQuery(oldpk_psnclsql, new ColumnProcessor());
						formValues.setFd_3d100d23eef7e2(oldpk_psncl);
						String newpk_psnclsql="select name from bd_psncl where pk_psncl = '"+(vos.getParentVO().getAttributeValue("newpk_psncl")==null?null:vos.getParentVO().getAttributeValue("newpk_psncl").toString())+"'";
						String newpk_psncl=  (String)dao.executeQuery(newpk_psnclsql, new ColumnProcessor());
						formValues.setFd_3d10314e46724c(newpk_psncl);
						String pk_old_hrcm_orgsql="select name from org_hrorg where pk_hrorg = '"+(vos.getParentVO().getAttributeValue("pk_old_hrcm_org")==null?null:vos.getParentVO().getAttributeValue("pk_old_hrcm_org").toString())+"'";
						String pk_old_hrcm_org=  (String)dao.executeQuery(pk_old_hrcm_orgsql, new ColumnProcessor());
						formValues.setFd_3d103172f69e7e(pk_old_hrcm_org);
						formValues.setFd_3d1039664a6468(vos.getParentVO().getAttributeValue("isrelease").toString().equals("Y")?"1":"0");
						formValues.setFd_3d1039713a57ee(vos.getParentVO().getAttributeValue("isend").toString().equals("Y")?"1":"0");
						formValues.setFd_3d1039a4060294(vos.getParentVO().getAttributeValue("ifaddblack").toString().equals("Y")?"1":"0");
						formValues.setFd_3d10398da3e252(vos.getParentVO().getAttributeValue("addreason")==null?null:vos.getParentVO().getAttributeValue("addreason").toString());
						formValues.setFd_3d1039a45a73a2(vos.getParentVO().getAttributeValue("isdisablepsn").toString().equals("Y")?"1":"0");

						String billmakercodesql="select user_code from sm_user where cuserid = '"+(vos.getParentVO().getAttributeValue("billmaker")==null?null:vos.getParentVO().getAttributeValue("billmaker").toString())+"'";
						String billmakercode=  (String)dao.executeQuery(billmakercodesql, new ColumnProcessor());
						formValues.setFd_3d100ee5c2d49e(billmakercode);//申请人工号
						String pk_psnjobcodesql="select code from bd_psndoc where pk_psndoc = '"+(vos.getParentVO().getAttributeValue("pk_psndoc")==null?null:vos.getParentVO().getAttributeValue("pk_psndoc").toString())+"'";
						String pk_psnjobcode=  (String)dao.executeQuery(pk_psnjobcodesql, new ColumnProcessor());
						formValues.setFd_3d100d27e56c9c(pk_psnjobcode);//转正人员工号
						String oldpk_deptcodesql="select code from org_dept where pk_dept = '"+(vos.getParentVO().getAttributeValue("oldpk_dept")==null?null:vos.getParentVO().getAttributeValue("oldpk_dept").toString())+"'";
						String oldpk_deptcode=  (String)dao.executeQuery(oldpk_deptcodesql, new ColumnProcessor());
						formValues.setFd_3d100ed110c344(oldpk_deptcode);
						// 将实体转换为JSON字符串
						try {
							String jsonFormValues = objectMapper.writeValueAsString(formValues);
							String docSubject = "接口发起离职流程";
							String docCreator = "{\"PersonNo\":\""+billmakercode+"\"}";
							String sendreturn = SendToKR.AddNewsInRestTemplate(jsonFormValues,docSubject,docCreator,ComparisonEnum.FORM_resignation.getFormId(),ComparisonEnum.FORM_resignation.getProcessId());
							if(sendreturn.contains("error")) {
								throw new BusinessException("推送EKP系统失败，错误信息："+sendreturn);
							}
						} catch (IOException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}}}}

			return retObj;
		} catch (Exception ex) {
			if (ex instanceof BusinessException) {
				throw (BusinessException)ex;
			}
			throw new PFBusinessException(ex.getMessage(), ex);
		}
	}
}


/* Location:              D:\QFHOME\home\home\modules\hrtrn\lib\pubhrtrn_transmgt.jar!/nc/bs/pub/action/N_6115_SAVE.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.0.7
 */